#pragma once
#include "eqobject.h"

namespace equipment
{

typedef enum _EQ_MODULE_ACTION
{
	EQM_ACT_NONE = 0,
	// general action, shared by several modules
	EQM_ACT_PROCESS,
	EQM_ACT_PREPARE_MOVE_WAFER_IN,
	EQM_ACT_PREPARE_MOVE_WAFER_OUT,
	// action of process module
	EQM_ACT_PM_CLEAN,
	EQM_ACT_PM_OPEN_SV,
	EQM_ACT_PM_CLOSE_SV,
	// action of transfer module
	EQM_ACT_TM_GET_WAFER_FROM_PM,
	EQM_ACT_TM_GET_WAFER_FROM_LL,
	EQM_ACT_TM_PUT_WAFER_TO_PM,
	EQM_ACT_TM_PUT_WAFER_TO_LL,
	EQM_ACT_TM_PUMPDOWN,
	EQM_ACT_TM_BACKFILL,
	EQM_ACT_TM_OPEN_SV,
	EQM_ACT_TM_CLOSE_SV,
	// action of load lock module
	EQM_ACT_LL_OPEN_SV,
	EQM_ACT_LL_CLOSE_SV,
	// action of EFEM module
	EQM_ACT_EFEM_ROBOT_GET_WAFER_FROM_FOUP,
	EQM_ACT_EFEM_ROBOT_GET_TWO_WAFER_FROM_FOUP,
	EQM_ACT_EFEM_ROBOT_GET_WAFER_FROM_COOL,
	EQM_ACT_EFEM_ROBOT_GET_WAFER_FROM_ALIGNER,
	EQM_ACT_EFEM_ROBOT_PUT_WAFER_TO_FOUP,
	EQM_ACT_EFEM_ROBOT_PUT_WAFER_TO_COOL,
	EQM_ACT_EFEM_ROBOT_PUT_WAFER_TO_ALIGNER,

} EQ_MODULE_ACTION;

typedef struct _EQM_ACT_INFO
{
	EQ_MODULE_ACTION action;
	int start_time; // relative to the start time of the current AutoRun.
} EQM_ACT_INFO;

class EqModule :
	public EqObject
{
public:
	EqModule(void);
	~EqModule(void);

	enum _RA_RESULT
	{
		RA_SUCCESS = 0,
		RA_FAILED,
		RA_UNSUPPORTED_ACTION,
	};

	void DefineAction(
		EQ_MODULE_ACTION action,
		int action_time           // millisecond
		);

	int RunAction(
		EQ_MODULE_ACTION action
		);

	virtual bool IsBusy();

private:
	map<EQ_MODULE_ACTION, int> m_supported_action_map;

	map<EQ_MODULE_ACTION, EQM_ACT_INFO> m_current_actions_map;
	CRITICAL_SECTION m_current_actions_map_lock;
};

}